<template>
  <div class="yueke">
    <Myhead :list="list" @changeTab="changeTab"></Myhead>
    <mypiehuan
      @changHot="changHot"
      @sort="sort"
      @changeTime="changeTime"
      :cur="cur"
    ></mypiehuan>
    <MylistCard
      v-for="(item, index) in yueke"
      :key="index"
      :item="item"
      @click.native="add(item.id)"
    ></MylistCard>
  </div>
</template>

<script>
import Myhead from "@/components/yueke/myhead";
import mypiehuan from "@/components/yueke/mypiehuan";
import MylistCard from "@/components/yueke/MylistCard";
import { getYuekeList } from "../../utils/api";
import { getYuekeHead } from "../../utils/api";
import { getYekeHeadlist } from "../../utils/api";
import { getYekeHot } from "../../utils/api";
import { getYekeTime, getYuekeSorts, getYuekeSortj } from "../../utils/api";
export default {
  data() {
    return {
      yueke: [],
      list: [],
      cur: 0,
    };
  },
  mounted() {
    getYuekeList().then((res) => {
      // console.log(res.data.list);
      this.yueke = res.data.list;
    });
    getYuekeHead().then((res) => {
      // console.log(res.data);
      this.list = res.data;
    });
  },
  methods: {
    changeTab(index) {
      getYekeHeadlist(index).then((res) => {
        // console.log(res.data);
        this.yueke = res.data.list;
      });
    },
    add(id) {
      // console.log(item);
      this.$router.push({ path: "/Yuekexp", query: { id } });
    },
    changHot() {
      getYekeHot().then((res) => {
        //  console.log(res);
        this.yueke = res.data.list;
        this.cur = 0;
      });
    },
    changeTime() {
      getYekeTime().then((res) => {
        //  console.log(res);
        this.yueke = res.data.list;
        this.cur = 0;
      });
    },
    sort(cur) {
      if (cur == 0) {
        getYuekeSorts().then((res) => {
          // console.log(res);
          this.cur = 1;
          this.yueke = res.data.list;
        });
      }
      if (cur == 1) {
        getYuekeSortj().then((res) => {
          // console.log(res);
          this.cur = 2;
          this.yueke = res.data.list;
        });
      }
      if (cur == 2) {
        getYuekeSorts().then((res) => {
          // console.log(res);
          this.cur = 1;
          this.yueke = res.data.list;
        });
      }
    },
  },
  components: {
    Myhead,
    mypiehuan,
    MylistCard,
  },
};
</script>

<style lang='scss' scoped>
.yueke {
  background-color: #f6f6f6;
}
.lb {
  width: 95%;
  height: 110px;
  border: 1px rgb(235, 233, 233) solid;
  border-radius: 9px;
  background-color: rgb(248, 252, 255);
  margin: 10px;
  display: flex;
  .img {
    // border: 1px red solid;
    width: 80px;
    height: 80px;
    margin-top: 15px;
    margin-left: 10px;
    border-radius: 50%;
    display: flex;
    img {
      width: 100%;
      border-radius: 50%;
    }
  }
  .name {
    // border: 1px rgb(235, 233, 233) solid;
    width: 198px;
    height: 30px;
    font-size: 16px;
    margin-top: 20px;
    margin-left: 30px;
    span {
      // display: block;
      // border: 1px rgb(235, 233, 233) solid;
      height: 20px;
      //   margin-top: 25px;
      font-size: 10px;
      margin-left: 8px;
      color: rgb(241, 122, 42);
    }
  }
  p {
    position: absolute;
    left: 127px;
    // top: 20px;
    font-size: 13px;

    height: 20px;
    color: rgb(109, 106, 106);
    // border: 1px rgb(235, 233, 233) solid;
    margin-top: 50px;
  }
  .nl {
    position: absolute;
    left: 130px;
    color: rgb(255, 0, 0);
    // top: 20px;
    height: 20px;
    // border: 1px rgb(235, 233, 233) solid;
    margin-top: 80px;
  }
  .zhiye {
    position: absolute;
    left: 200px;
    // top: 20px;
    color: rgb(194, 190, 190);
    height: 20px;
    // border: 1px rgb(235, 233, 233) solid;
    margin-top: 70px;
  }
  button {
    width: 50px;
    height: 30px;
    background-color: rgb(255, 102, 0);
    color: white;
    border: 1px rgb(255, 102, 0) solid;
    border-radius: 5px;
    margin-top: 40px;
    margin-left: 60px;
  }
}
</style>
